
import javax.swing.*;
import java.util.Calendar;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

/**
 * @program: attend-server
 * @description: MyDialog
 * @author: Yuwl
 * @create: 2020-01-06 17:43
 **/
public class Check {

	public static void main(String[] args) throws Exception {
		//JOptionPane.showMessageDialog(null, "该打卡了", "打卡", JOptionPane.WARNING_MESSAGE);
		Runnable runnable = new Runnable() {
			@Override
			public void run() {
				//System.out.println("hello...");
				JOptionPane.showMessageDialog(null, "<html><font size=16>检查任务，收活了^_^</font></html>", "收活", JOptionPane.WARNING_MESSAGE);
			}
		};
		Calendar calendar = Calendar.getInstance();
		calendar.add(Calendar.DATE,1);//每次启动都是明天的凌晨0点为开始执行时间(一定是明天的时间点，如果是今天的零点，今天的零点已经过去了，就不准了，他就以当前时间点为开始时间点，所以要以一个未到的时间点为开始时间)
		calendar.set(calendar.get(Calendar.YEAR),calendar.get(Calendar.MONTH),calendar.get(Calendar.DATE),17,30,0);
		long timeInterval = 24 * 60 * 60 * 1000;//一天的间隔
		ScheduledExecutorService service = Executors.newSingleThreadScheduledExecutor();
		service.scheduleAtFixedRate(runnable, calendar.getTimeInMillis()-System.currentTimeMillis(), timeInterval, TimeUnit.MILLISECONDS);

		System.out.println("检查任务，收活定时启动。。。");
	}
}
